using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OldMan_i_attack : MonoBehaviour
{
    Collider2D attackHitbox;
    float damage = 2f;
    void Start()
    {
        attackHitbox = GetComponent<Collider2D>();
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    void FixedUpdate()
    {

    }

    public void StartAttack(bool isFlip)
    {
        attackHitbox.enabled = true;
        if (isFlip)
        {
            attackHitbox.transform.localPosition = new Vector2(-0.3f, 0);
        }
        else {
            attackHitbox.transform.localPosition = new Vector2(0.3f, 0);
        }
    }

    public void StopAttack()
    {
        attackHitbox.enabled = false;
    }

    void OnTriggerEnter2D(Collider2D collider)
    {
        collider.SendMessage("OnHit", damage);
    }
}
